package com.hyjiacan.apps.audionly.data.model

import org.junit.jupiter.api.Test
import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.assertThrows

/**
 * FileProgress实体类的单元测试
 */
class FileProgressTest {
    @Test
    fun `test FileProgress creation and property access`() {
        // 创建测试对象
        val progress = FileProgress(
            taskId = "task1",
            progress = 50,
            speed = 1024,
            remainingTime = 60
        )

        // 验证属性值
        assertEquals("task1", progress.taskId)
        assertEquals(50, progress.progress)
        assertEquals(1024, progress.speed)
        assertEquals(60, progress.remainingTime)
    }

    @Test
    fun `test FileProgress progress update`() {
        // 创建测试对象
        val progress = FileProgress(
            taskId = "task1",
            progress = 50,
            speed = 1024,
            remainingTime = 60
        )

        // 更新进度
        progress.progress = 75
        progress.speed = 2048
        progress.remainingTime = 30

        // 验证更新后的属性值
        assertEquals(75, progress.progress)
        assertEquals(2048, progress.speed)
        assertEquals(30, progress.remainingTime)
    }

    @Test
    fun `test FileProgress copy method`() {
        // 创建原始对象
        val original = FileProgress(
            taskId = "task1",
            progress = 50,
            speed = 1024,
            remainingTime = 60
        )

        // 测试部分属性修改的复制
        val copied = original.copy(
            progress = 75,
            remainingTime = 30
        )

        // 验证复制后的对象
        assertEquals(original.taskId, copied.taskId)
        assertEquals(75, copied.progress)
        assertEquals(original.speed, copied.speed)
        assertEquals(30, copied.remainingTime)
    }

    @Test
    fun `test FileProgress invalid parameters`() {
        // 测试无效的进度值
        assertThrows<IllegalArgumentException> { FileProgress("task1", -1, 1024, 60) }
        assertThrows<IllegalArgumentException> { FileProgress("task1", 101, 1024, 60) }

        // 测试无效的速度值
        assertThrows<IllegalArgumentException> { FileProgress("task1", 50, -1, 60) }

        // 测试无效的剩余时间
        assertThrows<IllegalArgumentException> { FileProgress("task1", 50, 1024, -1) }
    }
}